<script lang="ts" setup>
	import { ref } from 'vue';
	import MessageInputView from "@/pages/im/conversation/MessageInputView";
	import NormalOutMessageContentView from "@/pages/im/conversation/message/NormalOutMessageContentContainerView";
	import NormalInMessageContentView from "@/pages/im/conversation/message/NormalInMessageContentContainerView";
	import NotificationMessageContentView from "@/pages/im/conversation/message/NotificationMessageContentView";
	import RecallNotificationMessageContentView from "@/pages/im/conversation/message/RecallNotificationMessageContentView";
	import NotificationMessageContent from "@/wfc/messages/notification/notificationMessageContent";
	import TextMessageContent from "@/wfc/messages/textMessageContent";
	import wfc from "@/wfc/client/wfc";
	import { numberValue, stringValue } from "@/wfc/util/longUtil";
	import MultiSelectActionView from "@/pages/im/conversation/MessageMultiSelectActionView";
	import ForwardType from "@/pages/im/conversation/message/forward/ForwardType";
	import FileMessageContent from "@/wfc/messages/fileMessageContent";
	import ImageMessageContent from "@/wfc/messages/imageMessageContent";
	import Message from "@/wfc/messages/message";
	import VideoMessageContent from "@/wfc/messages/videoMessageContent";
	import SoundMessageContent from "@/wfc/messages/soundMessageContent";
	import MessageContentType from "@/wfc/messages/messageContentType";
	import FavItem from "@/wfc/model/favItem";
	import ConversationType from "@/wfc/model/conversationType";
	import GroupMemberType from "@/wfc/model/groupMemberType";
	import CompositeMessageContent from "@/wfc/messages/compositeMessageContent";
	import ConnectionStatus from "@/wfc/client/connectionStatus";

	let conversationInfo = ref({});
	let sharedConversationState = ref({});
	let sharedContactState = ref({});
	let sharedPickState = ref(null);
	let sharedMiscState = ref(null);

	let savedMessageListViewHeight = ref(-1);
	let saveMessageListViewFlexGrow = ref(-1);

	let dragAndDropEnterCount = ref(0);

	let showContextMenu = ref(false);
	let isScroll = ref(false);
	let touchStartX = ref(0);
	let touchStartY = ref(0);
	let contextMenuX = ref(0);
	let contextMenuY = ref(0);
	let contextMenuItems = ref([]);
	let lastScrollTop = ref(0);
	let keyboardHeight = ref(0);
	let currentKeyboardHeight = ref(0);
	let scrollTop = ref(0);

	let triggered = ref(false);
</script>

<template>
	<view>
		<view v-if="sharedConversationState.currentConversationInfo == null" class="conversation-empty-container">
			<text>^~^</text>
		</view>
		<view v-else ref="conversationContentContainer" class="conversation-content-container"
			:dummy_just_for_reactive="currentVoiceMessage">
			<view class="message-list-container">
				<scroll-view ref="conversationMessageList" class="message-list" scroll-y="true" :scroll-top="scrollTop"
					:scroll-into-view="'id-' + lastMessageId" refresher-enabled="true" :refresher-triggered="triggered"
					:refresher-threshold="45" refresher-background="lightgreen" @refresherpulling="onPulling"
					@refresherrefresh="onRefresh" @refresherrestore="onRestore" @refresherabort="onAbort"
					@scroll="onScroll">
					<view v-for="(message) in sharedConversationState.currentConversationMessageList"
						:id="'id-'+ message.messageId" :key="message.messageId">
						<!--todo 不同的消息类型 notification in out-->

						<NotificationMessageContentView :message="message" v-if="isNotificationMessage(message)" />
						<RecallNotificationMessageContentView :message="message"
							v-else-if="isRecallNotificationMessage(message)" />
						<NormalOutMessageContentView
							@click.native.capture.stop="sharedConversationState.enableMessageMultiSelection? clickMessageItem($event, message) : null"
							:message="message" @touchstart.native="onTouchStart" @touchmove.native="onTouchMove"
							v-else-if="message.direction === 0 && sharedConversationState.enableMessageMultiSelection" />
						<NormalOutMessageContentView :message="message" @touchstart.native="onTouchStart"
							@touchmove.native="onTouchMove"
							v-else-if="message.direction === 0 && !sharedConversationState.enableMessageMultiSelection" />
						<NormalInMessageContentView
							@click.native.capture.stop="sharedConversationState.enableMessageMultiSelection ? clickMessageItem($event, message) : null"
							:message="message" @touchstart.native="onTouchStart" @touchmove.native="onTouchMove"
							v-else-if="message.direction === 1 && sharedConversationState.enableMessageMultiSelection" />
						<NormalInMessageContentView :message="message" @touchstart.native="onTouchStart"
							@touchmove.native="onTouchMove" v-else />
					</view>
				</scroll-view>
			</view>
			<!--            <view v-show="!sharedConversationState.enableMessageMultiSelection"-->
			<!--                  class="viewider-handler"></view>-->
			<chunLei-popups v-model="showContextMenu" :popData="contextMenuItems" @tapPopup="onContextMenuItemSelect"
				:x="contextMenuX" :y="contextMenuY" direction="column" theme="dark" :triangle="false" dynamic />
			<MessageInputView :conversationInfo="sharedConversationState.currentConversationInfo"
				v-show="!sharedConversationState.enableMessageMultiSelection" class="message-input-container"
				ref="messageInputView" />
			<MultiSelectActionView v-show="sharedConversationState.enableMessageMultiSelection" />
		</view>
	</view>
</template>

<style scoped>

</style>